This is the analysis script to prepare the data to run analyses for the project “Anxiety, depression and trauma symptom change during the COVID-19 pandemic: retrospective versus objective assessment” - Young et al (2020)
Script written by K L Purves, K N Thompson, C Huebel and M Davies. Email: kirstin.purves@kcl.ac.uk, katie.thompson@kcl.ac.uk, christopher.1.huebel@kcl.ac.uk, molly.davies@kcl.ac.uk
#Set up
Clear global environment
Retrieve the current date to use it for file endings to not overwrite files when one exports files
#Packages Install packages (if they are not available in your version of R)
Load packages
Registered S3 method overwritten by 'pryr':
method from
print.bytes Rcpp
For best results, restart R session and update pander using devtools:: or remotes::install_github('rapporter/pander')
Attaching package: 'polycor'
The following object is masked from 'package:psych':
polyserial
corrplot 0.84 loaded
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
✓ ggplot2 3.3.2 ✓ purrr 0.3.4
✓ tibble 3.0.4 ✓ dplyr 1.0.2
✓ tidyr 1.1.2 ✓ stringr 1.4.0
✓ readr 1.3.1 ✓ forcats 0.5.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
x ggplot2::%+%() masks psych::%+%()
x ggplot2::alpha() masks psych::alpha()
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
x tibble::view() masks summarytools::view()
FunctionLib/lm_forest.R FunctionLib/lm_formula.R
value ? ?
visible FALSE FALSE
FunctionLib/lm_output.R FunctionLib/raincloud.R
value ? ?
visible FALSE FALSE
Define colours for plotting this are the standard coping colours
Choose in this chunk which palette to use 04.07.2020 - Default to 2 colour COPING palette
Set up ggplot theme for the plots
[1] 34465 643
[1] "gad.sum_score_prepan" "pcl.sum_score_prepan"
[3] "phq.sum_score_prepan" "phq.sum_score_8items_prepan"
[5] "ocir.sum_score_prepan" "gad.sum_score_base"
[7] "gad.sum_score_retro" "pcl.sum_score_base"
[9] "pcl.sum_score_retro" "phq.sum_score_base"
[11] "phq.sum_score_8items_base" "phq.sum_score_retro"
[13] "phq.sum_score_8items_retro" "ocir.sum_score_base"
[15] "ocir.sum_score_retro"
[1] "phq.sum_score_prepan" "phq.sum_score_base" "phq.sum_score_retro"
[1] "gad.sum_score_prepan" "gad.sum_score_base" "gad.sum_score_retro"
[1] "ocir.sum_score_prepan" "ocir.sum_score_base" "ocir.sum_score_retro"
[1] "pcl.sum_score_prepan" "pcl.sum_score_base" "pcl.sum_score_retro"
[1] "phq.diff_score_retro_prepan" "phq.diff_score_base_prepan"
[3] "phq.diff_score_base_retro" "gad.diff_score_retro_prepan"
[5] "gad.diff_score_base_prepan" "gad.diff_score_base_retro"
[7] "pcl.diff_score_base_prepan" "ocir.diff_score_retro_prepan"
[9] "ocir.diff_score_base_prepan" "ocir.diff_score_base_retro"
[1] "phq.diff_score_retro_prepan" "phq.diff_score_base_prepan"
[3] "phq.diff_score_base_retro"
[1] "gad.diff_score_retro_prepan" "gad.diff_score_base_prepan"
[3] "gad.diff_score_base_retro"
[1] "ocir.diff_score_retro_prepan" "ocir.diff_score_base_prepan"
[3] "ocir.diff_score_base_retro"
Filter data frame to create 2 additional datasets. Additional exclusion criteria (beyond those listed above) are specified below:
Retro-baseline analyses
Note: make sure we impute retrospective data for those who did not change their feelings
Important note::: PCL does not have retrospective data, so we allow Baseline only or All prepandemic, baseline and retrospective OR Baseline and prepandemic data. Important logic here is that we need EVRYONE with ANY baseline data, but dont care about any other time point for this retrospective dataset for PCL.
[1] 32737 643
Prepan-baseline analyses Exclude individuals with NA for MHD, age, gender; exclude if prepan data collected after 1 March
[1] 12157 643
Prepan-baseline analyses Exclude individuals with NA for MHD, age, gender; exclude if prepan data collected after 1 March (to ensure comparability with prepan analyses)
[1] 10489 643
age^2 sensitivity Exclude individuals with NA for continuous Age variable
[1] 25814 643
[1] 24096 643
[1] 12157 643
Sensitivity analysis for individuals who signed up to GLAD (prepan) either 3, 6 or 9 months before the pendemic began.
#ANALYSIS PLAN 1. Calculate mean change per disorder group i. Disorders (9) a. Rank the disorders by the size of the change ii. Sex iii. Age (13; RAMP; potentially collapse above 65 depending on group sizes) iv. Ethnicity groups (5; White European, Black (British), Asian, Arab, Mixed)
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Table for knitting gad sum score summary table
| Change | Variable | Min | Max | Mean | Median | SD | Skew | Kurtosis |
|---|---|---|---|---|---|---|---|---|
| No change | Base | 0 | 21 | 2.740042 | 1 | 4.481334 | 2.1348352 | 4.2519780 |
| No change | Prepan | 0 | 21 | 7.993625 | 7 | 6.165962 | 0.5274724 | -0.8425302 |
| No change | Retro | 0 | 21 | 2.740042 | 1 | 4.481334 | 2.1348352 | 4.2519780 |
| Worsening | Base | 0 | 21 | 8.766138 | 7 | 5.693132 | 0.5145419 | -0.8093878 |
| Worsening | Prepan | 0 | 21 | 9.160358 | 8 | 5.869416 | 0.3772128 | -0.9054598 |
| Worsening | Retro | 0 | 21 | 4.658218 | 4 | 4.263868 | 1.3773597 | 1.9563781 |
| Improvement | Base | 0 | 21 | 4.767912 | 3 | 4.832619 | 1.3721605 | 1.5870653 |
| Improvement | Prepan | 0 | 21 | 9.046937 | 8 | 5.804418 | 0.3595536 | -0.8773999 |
| Improvement | Retro | 0 | 21 | 8.337588 | 7 | 5.489836 | 0.5192540 | -0.5883912 |
| NA | Base | 0 | 21 | 5.722222 | 5 | 5.816102 | 1.0412406 | 0.2319193 |
| NA | Prepan | 0 | 21 | 10.000000 | 13 | 8.563488 | -0.0313927 | -1.9895986 |
| NA | Retro | Inf | -Inf | NaN | NA | NA | NA | NA |
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in min(., na.rm = T): no non-missing arguments to min; returning Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Warning in max(., na.rm = T): no non-missing arguments to max; returning -Inf
Table for knitting gad diff summary table
| Change | Variable | Min | Max | Mean | Median | SD | Skew | Kurtosis |
|---|---|---|---|---|---|---|---|---|
| No change | Base - prepan | -21 | 20 | -2.0355457 | -1 | 4.695963 | -0.4873054 | 1.5249971 |
| No change | Base - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| No change | Prepan - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| Worsening | Base - prepan | -18 | 21 | 1.0244339 | 1 | 5.272565 | -0.0232123 | 0.6264062 |
| Worsening | Base - retro | -21 | 21 | 4.1083717 | 3 | 4.319494 | 0.7492612 | 0.9033930 |
| Worsening | Prepan - retro | -21 | 18 | -3.4649078 | -3 | 5.071721 | -0.3175882 | 0.4750981 |
| Improvement | Base - prepan | -21 | 12 | -3.9601911 | -3 | 5.470385 | -0.2955275 | 0.1734936 |
| Improvement | Base - retro | -21 | 21 | -3.5651408 | -3 | 5.333376 | 0.4506964 | 2.0385927 |
| Improvement | Prepan - retro | -21 | 20 | 0.4334661 | 1 | 5.679098 | -0.1488051 | 0.8650700 |
| NA | Base - prepan | -9 | 6 | -1.5000000 | -2 | 5.431390 | 0.0468089 | -1.6798094 |
| NA | Base - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
| NA | Prepan - retro | Inf | -Inf | NaN | NA | NA | NA | NA |
makes this into percentages
Warning: Removed 60925 rows containing non-finite values (stat_count).
Warning: Removed 35523 rows containing non-finite values (stat_bin).
Warning: Removed 35523 rows containing non-finite values (stat_bin).
Warning: Removed 25402 rows containing non-finite values (stat_bin).
Warning: Removed 21890 rows containing non-finite values (stat_bin).
Warning: Removed 21890 rows containing non-finite values (stat_bin).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 21890 rows containing non-finite values (stat_ydensity).
Warning: Removed 21890 rows containing non-finite values (stat_summary).
Warning: Removed 21890 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 21890 rows containing non-finite values (stat_ydensity).
Warning: Removed 21890 rows containing non-finite values (stat_summary).
Warning: Removed 21890 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 21890 rows containing non-finite values (stat_ydensity).
Warning: Removed 21890 rows containing non-finite values (stat_summary).
Warning: Removed 21890 rows containing missing values (geom_point).
Warning: `fun.y` is deprecated. Use `fun` instead.
Warning: `fun.ymin` is deprecated. Use `fun.min` instead.
Warning: `fun.ymax` is deprecated. Use `fun.max` instead.
Warning: Removed 21890 rows containing non-finite values (stat_ydensity).
Warning: Removed 21890 rows containing non-finite values (stat_summary).
Warning: Removed 21890 rows containing missing values (geom_point).